#include <iostream>
using namespace std;


int q;
string s;
int main()
{
    cin >> q;
    while (q--)
    {
        cin >> s;
        int n = s.size();
        for (int i = n - 1; i >= 0; i--)
        {
            if ((s[i] - '0') % 2 == 0)
            {
                swap(s[i], s[n - 1]);
                break;
            }
        }
        if ((s[n - 1] - '0') % 2 == 0)
            cout << s << endl;
        else
            cout << -1 << endl;
    }
    return 0;
}

 struct TreeNode {
    int val;
 	struct TreeNode *left;
 	struct TreeNode *right;
 	TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
  };

class Solution {
public:

    int ret = -1001;
    int func(TreeNode* root)
    {
        if (root == nullptr) return 0;
        int l = max(0, func(root->left));
        int r = max(0, func(root->right));

        ret = max(ret, root->val + l + r);

        return root->val + max(l, r);

    }
    int maxPathSum(TreeNode* root)
    {
        func(root);
        return ret;
    }
};